<script type="text/javascript">
    var linkrenderer = function (row, column, value) {
        var html = "<a href='{{base_url()}}huong-dan/"+value+"' class='a lh24 pl8' target='_blank'>"+value+"</a>";
        return html;
    }
    function jqxFixColumns(columns){
        columns['Alias'].cellsrenderer=linkrenderer;
        return columns;
    }
    function handleEvent_jqxGrid(jqxgrid){
        jqxgrid.bind('cellendedit', function (event) {
            try{
                var args = event.args;
                var Column = args.datafield ,Row = args.rowindex,Value = args.value;
                var Data=jqxgrid.jqxGrid('getrowdata', Row);
                var ID=Data.ID;
                if(ID==undefined || ID==""){
                    return;
                }
                switch(Column){
                    case "Status":
                        updateCol("status",ID,Value);
                        break;
                    default:
                    tipMessage("Unkown this cell. Maybe 'editable' of this colums is 'off'"); 
                }
            }catch(e){
                tipMessage(e.message);
                console.log("Error:"+e.message);
            }
        });
    }
    function SaveItem(){
        try{
            if(isrunning)return;
            console.log("Save ↵ Call");
            var ID,Title,Thumb,Content;                                
            ID = $('#txtID').val();
            Type=$('#cbxType').val();
            Title = $('#txtTitle').val();
            Content = tinyMCE.get('txtContent').getContent();//$('#txtContent').getCode();//areaContent.instanceById('txtContent').getContent();//
            var url="{{base_url()}}APanel/{{$controller}}/Save";
            var data={
                ID              :   ID,
                Title           :   Title,
                Type            :   Type,
                Content         :   Content
            }
            //ShowNoticeDialogMessage($("<div />").text(Content).html());return;
            console.log(data);
            isrunning=true;
            jqxAjax(url,data,function(result){
                isrunning=false;
                if(result.code>=0){
                    myjqxGrid.CancelEdit();
                    myjqxGrid.Refresh();
                }else{
                    tipMessage(result.msg);
                }
            });
        }catch(e){
            console.log("JSON Error:"+e.message+"\n↵ Error");
            tipMessage(e.message);
            //ShowErrorDialogMessage("Sorry. Your request could not be completed.<br/> Please check your input data.");
        }
    }
</script>